# app/api/common/responses.py

from fastapi import APIRouter
from pydantic import BaseModel
from typing import Dict, Any

from config.settings import settings

router = APIRouter()

class HealthResponse(BaseModel):
    """健康检查响应模型"""
    status: str
    message: str
    version: str
    timestamp: str

class SystemInfoResponse(BaseModel):
    """系统信息响应模型"""
    project_name: str
    version: str
    description: str
    api_endpoints: Dict[str, str]

@router.get("/health", response_model=HealthResponse, summary="健康检查")
async def health_check():
    """API健康检查"""
    import datetime
    return HealthResponse(
        status="healthy",
        message="多模态RAG系统运行正常",
        version=settings.VERSION,
        timestamp=datetime.datetime.now().isoformat()
    )

@router.get("/info", response_model=SystemInfoResponse, summary="系统信息")
async def system_info():
    """获取系统信息"""
    return SystemInfoResponse(
        project_name=settings.PROJECT_NAME,
        version=settings.VERSION,
        description="多模态RAG系统 - 支持文件上传和智能问答",
        api_endpoints={
            "upload_api": f"http://{settings.API_HOST}:{settings.UPLOAD_API_PORT}/docs",
            "rag_api": f"http://{settings.API_HOST}:{settings.RAG_API_PORT}/docs",
            "celery_monitor": f"http://{settings.API_HOST}:5555"
        }
    )

@router.get("/config", summary="获取配置信息")
async def get_config():
    """获取系统配置信息（不包含敏感信息）"""
    return {
        "project_name": settings.PROJECT_NAME,
        "version": settings.VERSION,
        "debug": settings.DEBUG,
        "milvus_host": settings.MILVUS_HOST,
        "milvus_port": settings.MILVUS_PORT,
        "upload_folder": settings.UPLOAD_FOLDER,
        "max_file_size_mb": settings.MAX_FILE_SIZE // (1024 * 1024),
        "allowed_extensions": settings.ALLOWED_EXTENSIONS,
        "chunk_size": settings.CHUNK_SIZE,
        "chunk_overlap": settings.CHUNK_OVERLAP,
        "top_k": settings.TOP_K,
        "similarity_threshold": settings.SIMILARITY_THRESHOLD
    } 